import {AfterViewInit, Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges} from "@angular/core";
import {MissionService} from "../../service/mission.service";
/**
 * Created by ZE-C on 2017/8/12.
 */
@Component({
  selector: 'hero-child',
  template: `
    <div class="z-box">


      <button >child btn confirm parent</button>
      
      <!--<div>hero-child {{name}}</div>-->
    </div>
    <!-- <div>hero-child {{index}}</div>-->
  `,
  styleUrls: []
})

export class HeroChildComponent{

  constructor(missionService:MissionService){
    missionService.publishObservable.subscribe( mes=> { this.handleMes(mes) })
  }
  handleMes( mes ){
    console.log(`child: handleMes(${mes})`)
  }


/*  ngAfterViewInit(): void {
    console.log('child: ngAfterViewInit()')

  }

  ngOnInit(): void {
    console.log('child: ngOnInit()')
  }

  constructor(  ){
    console.log('child: constructor()')
  }



  childName = 'child01'
  // local child
  childFunc(para){
    console.log(`child: childFunc(${para})`)
  }*/


  // Emitter
/*  confirmParent() {
    console.log('child: child is clicked')
    this.onVoted.emit('i am child')
  }

  @Output()
  onVoted = new EventEmitter<string>();*/

  /*@Input()
   name

   @Input()
   age

   ngOnChanges(changes: SimpleChanges): void {
   console.log(changes)
   }*/


  /*  private _name;

   @Input()
   set name( para : number ){
   this._name = para + 10 ;
   }

   get name(){
   return 200 + this._name
   }*/


  /*@Input()
   index : number;*/

  _id = 0;
}




